const app = getApp();
var config = app.globalData.config;
const http = require('../../utils/http.js');

Page({
	data: {
		status: ''
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady() {
		if (!app.login()) {
			return;
		}
	},
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad(options) {
		this.setData({
      status: options.status,
      detailid:options.id
    });
    this.teacherApprovalDetail();
  },
  teacherApprovalDetail() { //获取详情
    var that = this;
		http.httpPost(config.teacherApprovalDetail, {
			id: that.data.detailid
		}, function(e) {
			if (e.code == 1) {
				console.log(e);
				that.setData({
					'dataList': e.data
				});
			} 

		});
  },
  goCheckAttend(e){
    let id = e.currentTarget.dataset.id;
    let status = e.currentTarget.dataset.status;
    var that = this;
		http.httpPost(config.dGoApprove, {
      id: id,
      status:status
		}, function(e) {
			if (e.code == 1) {
        wx.showToast({
          title: e.msg,
          icon: 'none',
          duration: 2000,
          mask: true
        });

        setTimeout(() => {
          wx.redirectTo({
            url: '../approval/approvallist?status='+that.data.status
          });
        }, 2100);
			} 

		});

  },
	back() {
		wx.navigateBack({
			delta: 1,
		})
	},
	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage() {

	}
})
